<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>window属性parent演示</title>
    <style>
      div > iframe {
        width: 100%;
        height: 500px;
      }
      ._iframe {
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <h1>这个是标题...</h1>

    <button type="button" onclick="openNewWindow()">点击按钮</button>
    <div class="_iframe">
      <iframe src="targetDoc.html" frameborder="0" name="targetDoc"></iframe>
    </div>
    <div class="_iframe">
      <iframe src="window_top.html" frameborder="0" name="targetDoc"></iframe>
    </div>
    <script>
      function openNewWindow() {
        alert("parent:" + window.parent.location);
        alert("self:" + window.self.location);
        alert("top:" + window.top.location);
        window.open("https://www.163.com", "targetDoc");
      }
    </script>
  </body>
</html>
